<template>
  <div>
    <el-form label-width="100px" size="mini" class="form-view">
      <el-row>
        <el-col :span="8">
          <el-form-item label="标题" prop="title">
            {{ formItem.title }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="用途" prop="reason">
            {{ formItem.reason }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="申请部门" prop="orgName">
            {{ formItem.orgName }}
          </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
          <el-form-item label="综合管理部" prop="comprehensive">
            {{ formItem.comprehensive === true ? '是' :'否' }}
          </el-form-item>
        </el-col> -->
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            {{ formItem.remark }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="需求明细">
            <el-table
              :loading="false"
              :data="formItem.recipientRequires"
              border
              class="fixed-table-table"
              size="mini"
              max-height="240px"
            >
              <el-table-column
                label="序号"
                type="index"
                width="50"
                header-align="center"
                align="center"
              />
              <el-table-column v-for="column in insideColumns" :key="column.key" header-align="center" align="center" :label="column.title" :prop="column.key" :sortable="column.sortable">
                <template slot-scope="scope">
                  <column-render :render="column.render" :row="scope.row" :column="column" />
                </template>
              </el-table-column>
            </el-table>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { detail } from '@neu/dcam-ui/api/lingyongKJ'
// import PageableTable from '@neu/biz-core/components/PageableTable'
const formItem = {
  title: '', // 工单标题
  remark: '',
  workOrderNum: '',
  taskId: '',
  reason: '',
  comprehensive: true,
  recipientRequires: []
}
export default {
  components: {
    // PageableTable
  },
  props: {
    taskId: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderNum: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // 编辑的表单内容
      formItem: {
        ...formItem
      },
      insideColumns: [
        { title: '资产分类', key: 'type',
          render: (h, params) => {
            return h('span', params.row.bigTypeName + ' / ' + params.row.middleTypeName + ' / ' + params.row.smallTypeName)
          }
        },
        { title: '规格型号', key: 'specifications' },
        { title: '需求明细', key: 'detail' },
        { title: '领用数量', key: 'quantity' }
      ]
    }
  },
  created() {
    this.fetch()
  },
  methods: {
    fetch() {
      if (this.workOrderNum !== 'NULL') {
        detail(this.workOrderNum, this.taskId).then(response => {
          this.formItem = {
            ...response.data
          }
          if (this.formItem.categories === '3' || this.formItem.categories === '4') {
            this.insideColumns = this.insideColumns.filter(l => l.key !== 'bigTypeName' && l.key !== 'middleTypeName')
          }
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .fixed-table-table {
    margin: 8px 8px 8px 0;
  }
</style>
